Dynomotion

Group: DynoMotion Message: 789 From: likleong Date: 12/19/2010
Subject: Questions about the C program in Mach3 plug-in
Hi TK,

I am going to using Kflop with Mach3, I don't understand the C program inside the Mach 3 plug-in, just like the following section:

main()
{
int msg = persist.UserData[6]; // Mach3 notify Message 10000-10999

printf("Mach3 Notify Call, Message = %d\n",msg);


if (msg==10100)



What is "persist.UserData[6]"? Is it a variable inside the memory of Kflop or just a variable of Mach3? How about the others, like "persist.UserData[5]"....., any sumarized take for these kinds of variable? On the other hand, what is the meaning of the data value in these variable, like "msg==10100", what are they represent?

Finally, where can I get more information about the C program inside Mach3 plugin and is there any block diagram that explain the interaction between mach3, mach3 plug-in, Kflop DLL library and Kflop HW broad? Thanks a lot.


Best regards,
Benny
Group: DynoMotion Message: 790 From: Tom Kerekes Date: 12/19/2010
Subject: Re: Questions about the C program in Mach3 plug-in
Hi Benny,
 
This is a general mechanism that you can use when you want something in Mach3 to tell KFlop to do something.
 
First a unique notification message number between 10000 and 10999 should be chosen that will be the key to tell a KFlop C Program which action it should perform.  The KFlop Notify C Program should be written such that when it begins executing it should first check the message number to determine what action to perform.  In Mach3 VB when a NotifyPlugins(XX) is executed the plugins are notified of the message XX.  The Dynomotion Plugin will first write the message number XX int a KFlop global variable.  There are 100 global variables in KFlop declared as persist.UserData[0] through persist.UserData[99].  Which variable the message is stored into is configurable in the Mach3|Dynomotion|Configration page.  After the variable is stored the KFlop C Program will then execute.  Which C program is configurable also on the Configuration page along with which Thread Memory Space in KFlop that it should be loaded into.
 
So for example: assume we have configured the plugin for Notify to use a program called Notify.c, to pass the message code in variable 6 and to execute in thread 4.   Message code 10100 will be used to tell KFlop what to do.  Assume a Mach3 button "ZeroX" has VB code NotifyPlugins(10100) .  Here is the sequence:
 
#1 - User Pushes "ZeroX"
#2 - VB code NotifyPlugins(10100) executes
#3 - Plugin Stores code 10100 into KFlop persist.UserData[6]
#4 - Plugin Loads C program Notify.c into KFlop Thread 4
#5 - Notify.c program executes and detects code 10100 in persist.UserData[6]
 
I hope this helps.  There is more information here:
 
 
Regards
TK
 
 
 
 
 

 

Group: DynoMotion Message: 791 From: likleong Date: 12/19/2010
Subject: Re: Questions about the C program in Mach3 plug-in
Hi TK,

Thanks a lot for your prompt respond to my question, but now, I am a little bit confuse, in my understanding, Mach 3 should be interface with Kflop broad with your Mach3 plug-in, how come we still need to use a separate C program to handle some events generated by Mach3? Is it meaning that, if we don't handle these kinds of event/notification, the plug-in/kflop will just ignore them and finally some in-sync problem will be occured? Except the example stated in your website, like "home", "reset"....etc, is there any other circumstances that we must take care with?

On the other hand, from your example, seems it is just a one way communication, from mach3 to kflop (plug-in -> C program -> physical motion in Kflop broad), is it neccessary to give some feedback from kflop to Mach 3 right after it complete the instruction from the C (e.g notify.c) program?


Best regards,
Benny.


--- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@...> wrote:
>
> Hi Benny,
>
> This is a general mechanism that you can use when you want something in Mach3 to
> tell KFlop to do something.
>
> First a unique notification message number between 10000 and 10999 should be
> chosen that will be the key to tell a KFlop C Program which action it?should
> perform.??The KFlop Notify C Program?should be written such that when it begins
> executing it should first check the message number to determine what action to
> perform.??In Mach3 VB when a NotifyPlugins(XX) is executed the plugins are
> notified of the message XX.? The Dynomotion Plugin will first write the message
> number XX int a KFlop global variable.? There are 100 global variables in KFlop
> declared as persist.UserData[0] through persist.UserData[99].? Which variable
> the message is stored into is configurable in the Mach3|Dynomotion|Configration
> page.? After the variable is stored the KFlop C?Program will then execute.?
> Which?C program is configurable also on the Configuration page along with which
> Thread Memory Space in KFlop that it should be loaded into.
>
> So for example: assume we have configured the plugin for Notify to use a program
> called Notify.c, to pass the message code in variable?6 and to execute in thread
> 4.?? Message code 10100 will be used to tell KFlop what to do.? Assume a Mach3
> button "ZeroX" has VB code NotifyPlugins(10100) .? Here is the sequence:
>
> #1 - User Pushes "ZeroX"
> #2 - VB code NotifyPlugins(10100) executes
> #3 - Plugin Stores code 10100 into KFlop persist.UserData[6]
> #4 - Plugin Loads C program Notify.c into KFlop Thread 4
> #5 - Notify.c program executes and detects code 10100 in persist.UserData[6]
>
> I hope this helps.? There is more information here:
>
> http://www.dynomotion.com/Help/Mach3Plugin/Mach3Encoders.htm#Zero_Buttons
>
> Regards
> TK
>
>
>
>
>
>
> ?
>
>
>
> ________________________________
> From: likleong <likleong@...>
> To: DynoMotion@yahoogroups.com
> Sent: Sun, December 19, 2010 7:26:52 PM
> Subject: [DynoMotion] Questions about the C program in Mach3 plug-in
>
> ?
> Hi TK,
>
> I am going to using Kflop with Mach3, I don't understand the C program inside
> the Mach 3 plug-in, just like the following section:
>
> main()
> {
> int msg = persist.UserData[6]; // Mach3 notify Message 10000-10999
>
> printf("Mach3 Notify Call, Message = %d\n",msg);
>
> if (msg==10100)
>
> What is "persist.UserData[6]"? Is it a variable inside the memory of Kflop or
> just a variable of Mach3? How about the others, like "persist.UserData[5]".....,
> any sumarized take for these kinds of variable? On the other hand, what is the
> meaning of the data value in these variable, like "msg==10100", what are they
> represent?
>
> Finally, where can I get more information about the C program inside Mach3
> plugin and is there any block diagram that explain the interaction between
> mach3, mach3 plug-in, Kflop DLL library and Kflop HW broad? Thanks a lot.
>
> Best regards,
> Benny
>
Group: DynoMotion Message: 793 From: Tom Kerekes Date: 12/20/2010
Subject: Re: Questions about the C program in Mach3 plug-in
Hi Benny,
 
Handling the events in a C program allows total flexibility in how the event is handled.  For example when Mach3 sends the command to set the Spindle Speed the Spindle Program can set the speed in whatever manner is necessary for your system, whether it requires a DAC output voltage, PWM, Step/Dir Pulses, a Servo Axis, or anything else.  But yes if no Spindle Program is provided then the plugin will ignore the messages.  It shouldn't cause any "Sync problems".
 
The only notification from KFlop back to the Plugin is that the Program finished.
 
Regards
TK 

Group: DynoMotion Message: 796 From: likleong Date: 12/20/2010
Subject: Re: Questions about the C program in Mach3 plug-in
Hi TK,

From you manual, it said there are max 7 thread of C program can be store and execute in KFlop, but I have following questions regarding to this arrangment:

1. Is all this 7 C program stored in Fflop memory? In Flash or in RAM?
2. Will these program run automatically right after the unit power on?
3. How the broad these 7 C program together with instruction from USB port? Is it according to the mechanism of Premmetive multi-task you mentioned before?
4. In Mach3 plug-in, some C program will be called right after Mach3 startup, are they all downloaded to Kflop and stored under these 7 thread location? Will KmotionCNC do the same things?
5. If there priority arrangement between instruction from USB and these 7 program? What happen if there are some contradiction between them?



Best regards,
Benny.



--- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@...> wrote:
>
> Hi Benny,
>
> Handling the events in a C program allows total flexibility in how the event is
> handled.  For example when Mach3 sends the command to set the Spindle Speed the
> Spindle Program can set the speed in whatever manner is necessary for your
> system, whether it requires a DAC output voltage, PWM, Step/Dir Pulses, a Servo
> Axis, or anything else.  But yes if no Spindle Program is provided then the
> plugin will ignore the messages.  It shouldn't cause any "Sync problems".
>
> The only notification from KFlop back to the Plugin is that the Program
> finished.
>
> Regards
> TK 
>
>
>
>
> ________________________________
> From: likleong <likleong@...>
> To: DynoMotion@yahoogroups.com
> Sent: Sun, December 19, 2010 10:30:43 PM
> Subject: [DynoMotion] Re: Questions about the C program in Mach3 plug-in
>
>  
> Hi TK,
>
> Thanks a lot for your prompt respond to my question, but now, I am a little bit
> confuse, in my understanding, Mach 3 should be interface with Kflop broad with
> your Mach3 plug-in, how come we still need to use a separate C program to handle
> some events generated by Mach3? Is it meaning that, if we don't handle these
> kinds of event/notification, the plug-in/kflop will just ignore them and finally
> some in-sync problem will be occured? Except the example stated in your website,
> like "home", "reset"....etc, is there any other circumstances that we must take
> care with?
>
> On the other hand, from your example, seems it is just a one way communication,
> from mach3 to kflop (plug-in -> C program -> physical motion in Kflop broad), is
> it neccessary to give some feedback from kflop to Mach 3 right after it complete
> the instruction from the C (e.g notify.c) program?
>
> Best regards,
> Benny.
>
> --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> >
> > Hi Benny,
> >
> > This is a general mechanism that you can use when you want something in Mach3
> >to
> >
> > tell KFlop to do something.
> >
> > First a unique notification message number between 10000 and 10999 should be
> > chosen that will be the key to tell a KFlop C Program which action it?should
> > perform.??The KFlop Notify C Program?should be written such that when it begins
> >
> > executing it should first check the message number to determine what action to
>
> > perform.??In Mach3 VB when a NotifyPlugins(XX) is executed the plugins are
> > notified of the message XX.? The Dynomotion Plugin will first write the message
> >
> > number XX int a KFlop global variable.? There are 100 global variables in KFlop
> >
> > declared as persist.UserData[0] through persist.UserData[99].? Which variable
> > the message is stored into is configurable in the Mach3|Dynomotion|Configration
> >
> > page.? After the variable is stored the KFlop C?Program will then execute.?
> > Which?C program is configurable also on the Configuration page along with which
> >
> > Thread Memory Space in KFlop that it should be loaded into.
> >
> > So for example: assume we have configured the plugin for Notify to use a
> >program
> >
> > called Notify.c, to pass the message code in variable?6 and to execute in
> >thread
> >
> > 4.?? Message code 10100 will be used to tell KFlop what to do.? Assume a Mach3
>
> > button "ZeroX" has VB code NotifyPlugins(10100) .? Here is the sequence:
> >
> > #1 - User Pushes "ZeroX"
> > #2 - VB code NotifyPlugins(10100) executes
> > #3 - Plugin Stores code 10100 into KFlop persist.UserData[6]
> > #4 - Plugin Loads C program Notify.c into KFlop Thread 4
> > #5 - Notify.c program executes and detects code 10100 in persist.UserData[6]
> >
> > I hope this helps.? There is more information here:
> >
> > http://www.dynomotion.com/Help/Mach3Plugin/Mach3Encoders.htm#Zero_Buttons
> >
> > Regards
> > TK
> >
> >
> >
> >
> >
> >
> > ?
> >
> >
> >
> > ________________________________
> > From: likleong <likleong@>
> > To: DynoMotion@yahoogroups.com
> > Sent: Sun, December 19, 2010 7:26:52 PM
> > Subject: [DynoMotion] Questions about the C program in Mach3 plug-in
> >
> > ?
> > Hi TK,
> >
> > I am going to using Kflop with Mach3, I don't understand the C program inside
> > the Mach 3 plug-in, just like the following section:
> >
> > main()
> > {
> > int msg = persist.UserData[6]; // Mach3 notify Message 10000-10999
> >
> > printf("Mach3 Notify Call, Message = %d\n",msg);
> >
> > if (msg==10100)
> >
> > What is "persist.UserData[6]"? Is it a variable inside the memory of Kflop or
> > just a variable of Mach3? How about the others, like
> >"persist.UserData[5]".....,
> >
> > any sumarized take for these kinds of variable? On the other hand, what is the
>
> > meaning of the data value in these variable, like "msg==10100", what are they
> > represent?
> >
> > Finally, where can I get more information about the C program inside Mach3
> > plugin and is there any block diagram that explain the interaction between
> > mach3, mach3 plug-in, Kflop DLL library and Kflop HW broad? Thanks a lot.
> >
> > Best regards,
> > Benny
> >
>
Group: DynoMotion Message: 798 From: Tom Kerekes Date: 12/20/2010
Subject: Re: Questions about the C program in Mach3 plug-in
Hi Benny,
 
#1 - Both.  Programs are downloaded to RAM.  But the UserData (including programs) can be Flashed so it will be there after power up.  But this is not recommended.  It is simpler to just have the PC application load them each time. 
 
 
#2 - There is an option to launch each Thread immediately on power up.  See the Configuration/Flash Screen
 
 
#3 - The USB communication is processed by the System Thread 0.  The System Thread always gets its time slice.  Premptive Multitasking is described here:
 
 
#4 - Yes.  KMotionCNC will download programs as needed
 
#5 - The System Thread will always receive it's time slice and service the USB communication
 
Regards
TK